package cn.itcast.ssm.controller;

import cn.itcast.ssm.mapper.CropMapper;
import cn.itcast.ssm.po.Crop;
import cn.itcast.ssm.service.CropService;
import cn.itcast.ssm.service.impl.CropServiceImpl;
import cn.itcast.ssm.spring.ArchivesLog;
import cn.itcast.ssm.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;
/**
 * @author wsw
 * @Package cn.itcast.ssm.controller
 * @Description:
 * @date 19-3-14 下午14:30
 */
@SuppressWarnings("ALL")
@Controller
@RequestMapping(value = "/crop")
public class CropController {

    @Autowired
    CropService cropService;
    /**
     * 查询信息
     * @return
     */
    @ResponseBody
    @ArchivesLog(operationType = "查询信息", operationName = "查询所有农作物名字信息")
    @RequestMapping(value = "/selectAllCrop.action")
    public Map<String,Object> selectAllCrop(){
        List list=cropService.selectAllCropName();
        return R.ok().put("data",list);
    }
    /**
     * 查询信息
     * @param reMap
     * @return
     */
    @ResponseBody
    @ArchivesLog(operationType = "查询信息", operationName = "根据农作物名字查询该农作物信息")
    @RequestMapping(value = "/selectCropByName.action")
    public Map<String,Object> selectCropByName(@RequestBody Map<String,Object> reMap){
      String Name=(String)reMap.get("crop_name");
      Crop crop=cropService.selectCropByName(Name);
      return  R.ok().put("data",crop);
    }
}
